package com.csx.saas.platform.init.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.csx.basic.base.entity.TreeEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import java.time.LocalDateTime;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 产品分类
 * </p>
 *
 * @author ChenSongXin
 * @since 2021-03-03
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("saas_init_product_cate")
@ApiModel(value = "InitProductCate", description = "产品分类")
@AllArgsConstructor
public class InitProductCate extends TreeEntity<InitProductCate, Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 产品分类图(100*100)
     */
    @ApiModelProperty(value = "产品分类图(100*100)")
    @Length(max = 255, message = "产品分类图(100*100)长度不能超过255")
    @TableField(value = "img_url", condition = LIKE)
    @Excel(name = "产品分类图(100*100)")
    private String imgUrl;

    /**
     * 产品分类上级名称
     */
    @ApiModelProperty(value = "产品分类上级名称")
    @TableField(exist = false)
    private String parentName;


    @Builder
    public InitProductCate(Long id, String label, Long parentId, Integer sortValue, LocalDateTime createTime, Long createdBy, LocalDateTime updateTime, Long updatedBy, 
                    String imgUrl) {
        this.id = id;
        this.label = label;
        this.parentId = parentId;
        this.sortValue = sortValue;
        this.createTime = createTime;
        this.createdBy = createdBy;
        this.updateTime = updateTime;
        this.updatedBy = updatedBy;
        this.imgUrl = imgUrl;
    }

}
